package com.it.controller;


import cn.dev33.satoken.util.SaResult;
import com.github.pagehelper.PageInfo;
import com.it.bean.Application;
import com.it.bean.Swiper;
import com.it.page.PageImpl;
import com.it.page.PageQuery;
import com.it.service.SwiperService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
@RequestMapping("/swiper")
public class SwiperController {
    private final SwiperService swiperService;

    @PostMapping("/page")
    public SaResult page(@RequestBody PageQuery<Swiper> pageQuery) {
        PageInfo<Swiper> pageInfo = swiperService.page(pageQuery);
        return SaResult.data(PageImpl.of(pageInfo));
    }

    @PostMapping("/delete/{id}")
    public SaResult del(@PathVariable("id") Long id) {
        swiperService.delete(id);
        return SaResult.ok();
    }

    @PostMapping("/save")
    public SaResult save(@RequestBody Swiper swiper) {
        swiperService.save(swiper);
        return SaResult.ok();
    }
}